package com.generator;

import org.mybatis.generator.api.GeneratedXmlFile;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.PluginAdapter;

import java.lang.reflect.Field;
import java.util.List;

/**
 * @description:
 * @author: DHF
 * @date: 2019/1/4 000417:22
 */
public class MergePlugin extends PluginAdapter {

	public boolean validate(List<String> list) {
		return true;
	}


	@Override
	public boolean sqlMapGenerated(GeneratedXmlFile sqlMap, IntrospectedTable introspectedTable) {

		try {
			Field isMergeable = sqlMap.getClass().getDeclaredField("isMergeable");
			isMergeable.setAccessible(true);
			isMergeable.setBoolean(sqlMap, false);

		} catch (NoSuchFieldException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		return true;
	}
}
